//
//  MenkNavigationController.m
//  MenkNav
//
//  Created by Burn on 2019/6/13.
//  Copyright © 2019 menksoft. All rights reserved.
//

#import "MenkNavigationController.h"
#import "MenkNavnigationBar.h"
#import "Macro.h"

@interface MenkNavigationController ()

@end

@implementation MenkNavigationController

+ (void)initialize{
    
    // !!!: Set Appearance Color
    UINavigationBar *bar = [UINavigationBar appearance];
    [bar setBarTintColor:RGBACOLOR(55, 207, 240, 1)];
    
    // !!!: Set Title TextColor and Font
//    bar.titleTextAttributes = @{NSForegroundColorAttributeName: RGBACOLOR(150, 150, 150, 1),NSFontAttributeName : HvrStudioChaganTig_M(20)};
    
    // !!!: Set Bar ItemText Color
    [bar setTintColor:RGBACOLOR(102, 102, 102, 1)];
    

}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    // !!!: Set Bar BackGroundImage
    [self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    
    // !!!: Set Bar Botton Line
    [self.navigationBar setShadowImage:[UIImage new]];
    
    [self.navigationItem setHidesBackButton:YES];
}



- (void)viewDidLoad {
    [super viewDidLoad];
    // !!!: Add Pop GesturePercognizer
    
    
    
//    [self setValue:nil forKey:@"tabBar"];
    UINavigationBar *bar = [self valueForKey:@"navigationBar"];
    bar.hidden = YES;
    //  添加手势事件
    self.interactivePopGestureRecognizer.delegate= (id)self;
}

- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    
    UINavigationBar *bar = [self valueForKey:@"navigationBar"];
    bar.hidden = YES;
}



#pragma mark - pushViewController
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    // !!!: Set Global PopBtn
    if (self.viewControllers.count >= 1) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
   

    [super pushViewController:viewController animated:animated];
}

-(UIBarButtonItem *)creatBackButton{
    
    return [[UIBarButtonItem alloc]initWithImage:[[UIImage new] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]style:UIBarButtonItemStylePlain target:self action:nil];
    
}

-(void)popSelf{
    [self popViewControllerAnimated:YES];
}


- (BOOL)shouldAutorotate {
    return [self.visibleViewController shouldAutorotate];
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return [self.visibleViewController supportedInterfaceOrientations];
}


- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return [self.visibleViewController preferredInterfaceOrientationForPresentation];
}



@end
